package com.ljs.springloopdependencies.main;

import com.ljs.springloopdependencies.bean.B;
import com.ljs.springloopdependencies.bean.Book;
import com.ljs.springloopdependencies.bean.Book1;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 要将这个类作为组件
 */
@Component
public class GetBean  {
    @Resource(name = "Book1")
    Book1 book1;
    public  Book getFormXml(){
        //读取配置文件
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("bean1.xml");
        Book book=    applicationContext.getBean("book", Book.class);
        System.out.println(book);
        return book;
    }
    public  Book1 getConfig(){
        return book1;
    }
}
